package cn.caojun.org.service.impl;

import cn.caojun.auth.domain.Role;
import cn.caojun.auth.dto.EmployeeRoleDTO;
import cn.caojun.basic.service.impl.BaseServiceImpl;
import cn.caojun.basic.utils.PageList;
import cn.caojun.org.domain.Employee;
import cn.caojun.org.mapper.EmployeeMapper;
import cn.caojun.org.query.EmployeeQuery;
import cn.caojun.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl extends BaseServiceImpl<Employee> implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public List<Role> getRoleTree() {
        return employeeMapper.getRoleTree();
    }

    @Override
    public void setEmployeeRole(EmployeeRoleDTO employeeRoleDTO) {
        employeeMapper.deleteEmployeeById(employeeRoleDTO.getEmployeeId());
        employeeMapper.addEmployeeRole(employeeRoleDTO.getEmployeeId(),employeeRoleDTO.getRoleId());
    }

    @Override
    public List<String> getRoleById(Long roleId) {
        return employeeMapper.loadRoleById(roleId);
    }
}
